package com.lxmes.procontrol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.procontrol.domain.NcProOrderInfoBg;
import com.lxmes.procontrol.service.INcProOrderInfoBgService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 产线工位报工单Controller
 * 
 * @author 张志煜
 * @date 2022-12-30
 */
@RestController
@RequestMapping("/procontrol/orderInfoBg")
public class NcProOrderInfoBgController extends BaseController
{
    @Autowired
    private INcProOrderInfoBgService ncProOrderInfoBgService;

    /**
     * 查询产线工位报工单列表
     */
    @PreAuthorize("@ss.hasPermi('procontrol:orderInfoBg:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcProOrderInfoBg ncProOrderInfoBg)
    {
        startPage();
        List<NcProOrderInfoBg> list = ncProOrderInfoBgService.selectNcProOrderInfoBgList(ncProOrderInfoBg);
        return getDataTable(list);
    }

    /**
     * 导出产线工位报工单列表
     */
    @PreAuthorize("@ss.hasPermi('procontrol:orderInfoBg:export')")
    @Log(title = "产线工位报工单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcProOrderInfoBg ncProOrderInfoBg)
    {
        List<NcProOrderInfoBg> list = ncProOrderInfoBgService.selectNcProOrderInfoBgList(ncProOrderInfoBg);
        ExcelUtil<NcProOrderInfoBg> util = new ExcelUtil<NcProOrderInfoBg>(NcProOrderInfoBg.class);
        util.exportExcel(response, list, "产线工位报工单数据");
    }

    /**
     * 获取产线工位报工单详细信息
     */
    @PreAuthorize("@ss.hasPermi('procontrol:orderInfoBg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncProOrderInfoBgService.selectNcProOrderInfoBgById(id));
    }

    /**
     * 新增产线工位报工单
     */
    @PreAuthorize("@ss.hasPermi('procontrol:orderInfoBg:add')")
    @Log(title = "产线工位报工单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcProOrderInfoBg ncProOrderInfoBg)
    {
        return toAjax(ncProOrderInfoBgService.insertNcProOrderInfoBg(ncProOrderInfoBg));
    }

    /**
     * 修改产线工位报工单
     */
    @PreAuthorize("@ss.hasPermi('procontrol:orderInfoBg:edit')")
    @Log(title = "产线工位报工单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcProOrderInfoBg ncProOrderInfoBg)
    {
        return toAjax(ncProOrderInfoBgService.updateNcProOrderInfoBg(ncProOrderInfoBg));
    }

    /**
     * 删除产线工位报工单
     */
    @PreAuthorize("@ss.hasPermi('procontrol:orderInfoBg:remove')")
    @Log(title = "产线工位报工单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncProOrderInfoBgService.deleteNcProOrderInfoBgByIds(ids));
    }
}
